package com.happy.study.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class MvcWebConfig implements WebMvcConfigurer {


    @Override
    public void addViewControllers ( ViewControllerRegistry registry ) {
        registry.addViewController ( "/records" ).setViewName ( "record" ); // 加载考试记录页面
        registry.addViewController ( "/course" ).setViewName ( "courseList" ); // 加载笔记列表页面
        registry.addViewController ( "/note" ).setViewName ( "noteList" ); // 加载笔记列表页面
        registry.addViewController ( "/paper" ).setViewName ( "paperList" ); // 加载试卷列表页面
        registry.addViewController ( "/download" ).setViewName ( "download" ); // 加载试卷列表页面
        registry.addViewController ( "/question" ).setViewName ( "questionList" ); // 加载问题详情列表
        registry.addViewController ( "/agreement" ).setViewName ( "agreement" ); // 加载用户协议页面
    }

    @Resource
    private StudyInterceptor studyInterceptor;

    @Override
    public void addInterceptors ( InterceptorRegistry registry ) {
        registry.addInterceptor ( studyInterceptor ).addPathPatterns ( "/user/index" ).addPathPatterns ( "/user/center" ).addPathPatterns ( "/records" ).addPathPatterns ( "/record/queryList" ).addPathPatterns ( "/report/**" );//.addPathPatterns ( "/paper/**" ).excludePathPatterns ( "/paper/queryList" );
    }
}
